//1.二进制枚举
class Solution {
public:
    vector<vector<int>> subsets(vector<int>& nums) {
        vector<vector<int>> ret;
         vector<int> temp;
        int n = nums.size();
        for(int i = 0; i < (1<<n); ++i) {
           temp={};
            for(int j = 0; j < n; ++j) {
                if(i>>j&1)
                    temp.push_back(nums[j]);
            }
            ret.push_back(temp);
        }

        return ret;
    }
};

//2.递归
class Solution {
public:
    vector<int> t;
    vector<vector<int>> ans;

    void dfs(int cur, vector<int>& nums) {
        if (cur == nums.size()) {
            ans.push_back(t);
            return;
        }
        t.push_back(nums[cur]);
        dfs(cur + 1, nums);
        t.pop_back();
        dfs(cur + 1, nums);
    }

    vector<vector<int>> subsets(vector<int>& nums) {
        dfs(0, nums);
        return ans;
    }
};


